package com.neusoft.controller;

import com.neusoft.model.ActivitySearch;
import com.neusoft.po.Fullless;
import com.neusoft.service.FulllessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 打折活动请求控制器
 *
 * @author Lucifer
 * @since 2021/5/17 12:06
 */
@RestController
@RequestMapping("/fullless")
@Api(tags = "满减活动接口")
public class FulllessController {

    @Resource
    private FulllessService fulllessService;

    @PostMapping("/page")
    @ApiOperation("满减活动集合")
    public Object page(@RequestBody ActivitySearch pageSearch) {
        return fulllessService.page(pageSearch);
    }

    @PostMapping("/list")
    @ApiOperation("满减活动集合")
    public List<Fullless> list() {
        return fulllessService.listAll();
    }

    @GetMapping
    @ApiOperation("查询满减信息")
    @ApiImplicitParam(value = "满减ID", name = "id", required = true)
    public Fullless get(Integer id) {
        return fulllessService.getById(id);
    }

    @PostMapping
    @ApiOperation("保存满减")
    public Integer save(@RequestBody Fullless fullless) {
        fulllessService.save(fullless);
        return fullless.getId();
    }

    @DeleteMapping("/{ids}")
    @ApiOperation("批量满减活动删除")
    public Integer delete(@PathVariable("ids") Integer[] ids) {
        return fulllessService.delete(ids);
    }
}
